#include <bits/stdc++.h>
using namespace std;

const int N(1e5 + 5);
int n, m, l, V, d[N], v[N], a[N], p[N], sum;

struct Node{
    int lef, rig;
}node[N];

bool cmp(Node No, Node de){
    return No.rig < de.rig;
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while(T--){
        sum = 0;
        cin >> n >> m >> l >> V;
        for(int i = 1; i <= n; i++) cin >> d[i] >> v[i] >> a[i];
        for(int i = 1; i <= m; i++) cin >> p[i];
        for(int i = 1; i <= n; i++){
            int oldsum = sum;
            if(a[i] == 0){
                if(v[i] > V){
                    int le = lower_bound(p + 1, p + m + 1, d[i]) - p, ri = m;
                    if(le <= ri){
                        sum++;
                        node[sum].lef = le;
                        node[sum].rig = ri;
                    }
                }
            }else if(a[i] > 0){
                if(v[i] > V){
                    int le = lower_bound(p + 1, p + m + 1, d[i]) - p, ri = m;
                    if(le <= ri){
                        sum++;
                        node[sum].lef = le;
                        node[sum].rig = ri;
                    }
                }else{
                    int s = ceil(1.0 * (V * V - v[i] * v[i]) / 2 / a[i]);
                    if((V * V - v[i] * v[i]) % (2 * a[i]) == 0) s++;
                    int le = lower_bound(p + 1, p + m + 1, d[i] + s) - p, ri = m;
                    if(le <= ri){
                        sum++;
                        node[sum].lef = le;
                        node[sum].rig = ri;
                    }
                }
            }else{
                if(v[i] > V){
                    int s = floor(1.0 * (V * V - v[i] * v[i]) / 2 / a[i]);
                    int le = lower_bound(p + 1, p + m + 1, d[i]) - p, ri = upper_bound(p + 1, p + m + 1, d[i] + s) - p - 1;
                    if(le <= ri){
                        sum++;
                        node[sum].lef = le;
                        node[sum].rig = ri;
                    }
                }
            }
        }
        sort(node + 1, node + sum + 1, cmp);
        cout << sum << ' ';
        int cnt = 0, bac = -1;
        for(int i = 1; i <= sum; i++){
            if(bac < node[i].lef){
                cnt++;
                bac = node[i].rig;
            }
        }
        cout << m - cnt << '\n';
    }
    return 0;
}
